package cn.by.wms.enums;

import java.util.Arrays;
import java.util.Optional;

public enum PoStatus {
    NEW(1,"新建（待审核）"),
    APPROVE(10, "审核通过"),
    TRANSFER(20, "配货中"),
    FINISH(30, "入库（完成）"),
    REJECT(40, "拒绝(审核未通过)"),
    CANCEL(120, "作废");

    private int code;
    private String massage;

    private PoStatus() {
    }

    private PoStatus(int code, String massage) {
        this.code = code;
        this.massage = massage;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMassage() {
        return this.massage;
    }

    public void setMassage(String massage) {
        this.massage = massage;
    }

    public static PoStatus getProductStatusByCode(int code) {
        PoStatus[] values = PoStatus.values();
        Optional<PoStatus> first = Arrays.stream(values).filter(item -> item.getCode() == code).findFirst();
        return first.orElse(null);

    }
}
